//package com.dkm.interceptor;
//
//import java.io.IOException;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.aopalliance.intercept.Interceptor;
//import org.springframework.stereotype.Component;
//
//@Component
//public class RedirectInterceptor implements Interceptor {
//	//对于请求是ajax请求重定向问题的处理方法
//    public void reDirect(HttpServletRequest request, HttpServletResponse response) throws IOException{
//        
//    	System.out.println(1);
//    	//获取当前请求的路径
//        String basePath = request.getScheme() + "://" + request.getServerName() + ":"  + request.getServerPort()+request.getContextPath();
//        //如果request.getHeader("X-Requested-With") 返回的是"XMLHttpRequest"说明就是ajax请求，需要特殊处理
//        if("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))){
//            //告诉ajax我是重定向
//            response.setHeader("REDIRECT", "REDIRECT");
//            //告诉ajax我重定向的路径
//            response.setHeader("CONTENTPATH", basePath+"/login.html");
//            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
//        }else{
//            response.sendRedirect(basePath + "/login.html");
//        }
//    }
//}
